#ifndef CONSOLE_H_INCLUDED
#define CONSOLE_H_INCLUDED

#include "Atomic.h"

#include <cstdarg>

namespace CEngine
{

///
///A group of functions that controls the system console.
///
namespace Console {
    enum TextColour {
        BLACK = 0, BLUE, GREEN, AQUA, RED, PURPLE, YELLOW, WHITE,
        GRAY, LBLUE, LGREEN, LAQUA, LRED, LPURPLE, LYELLOW, LWHITE,
        RESET ///Resets the console's text to the default.
    };

    ///Prints the given string to the console using printf.
    ///extends printf's format specifiers with %q and %r.
    ///%q sets the text colour beyond that point. Formatted like: foreground + [optional](background * 16)
    ///%r resets the text to its original colours. Takes no argument.
    ///returns the number of characters printed.
    I32
    print(const char* stringToPrint, ...);

    ///Same as print but takes a va_list instead.
    I32
    vPrint(const char* stringToPrint, va_list args);

    ///Formats the given string and stores it in output up to length characters.
    ///%q and %r are stripped out, and do nothing.
    ///returns the number of characters that would have been printed (excluding \0).
    I32
    sPrint(char* output, U32 length, const char* stringToFormat, ...);

    ///Same as sPrint but takes a va_list instead.
    I32
    vsPrint(char* output, U32 length, const char* stringToFormat, va_list args);

    ///Reads data from the console using scanf.
    I32
    scan(const char* stringToPrint, ...);

    ///Same as the above but takes a va_list instead.
    I32
    vScan(const char* stringToPrint, va_list args);

    ///Sets the colour of the text printed in the console to the given colours.
    ///if either variable is RESET the text (foreground and background) is reset to the default.
    void
    setTextColour(const TextColour foreground, const TextColour background);

    ///returns the current console text colour.
    U8
    getTextColour(void);

    ///The default console text colour.
    const U8 defaultConsoleTextColour = getTextColour();
}

}

#endif // CONSOLE_H_INCLUDED
